const Koa = require('koa')
const path = require('path')
const views = require('koa-views')
const app = new Koa()

/* 加载模板引擎 */
app.use(views(
  path.join(__dirname, 'views'),
  {
    extension: 'ejs',
  }
))

app.use(async ctx => {
  const title = 'hellow koa2'
  await ctx.render('index', {
    title,
  })
})

app.listen(4000, () => {
  console.log('[demo] request post is starting at port 4000')
})